package org.example.controller;

import org.example.pojo.Photo;
import org.example.service.PhotoService;
import org.example.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/Photo")
public class PhotoController {

    @Autowired
    private PhotoService photoService;

    //添加图片
    @PostMapping("/addPhoto")
    public Result addPhoto(String id, String url, String location) {
        photoService.addPhoto(id, url, location);
        return Result.success();
    }

    //图片列表
    @GetMapping("/list")
    public Result<List<Photo>> list(String id) {
        List<Photo> list = photoService.list(id);

        return Result.success(list);
    }

    //图片的删除
    @DeleteMapping("/deletePhoto")
    public Result deletePhoto(String id) {
        photoService.deletePhoto(id);

        return Result.success();
    }

}
